function ajax_method(url, data, method, success) {
    var xhr = new XMLHttpRequest();
    if (method == "get") {
        if (date) {
            url += "?";
            url += data
        }
        ajax.open(method, url);
        ajax.send();
    }
    else {
        xhr.open(method, url);
        if (data) {
            xhr.send(data)
        } else {
            xhr.send();
        }
    }
    xhr.onreadystatechange = function () {
        if (ajax.readyState == 4 && ajax.status == 200)
            success(ajax.responseText)
    }
}
